<?php

namespace Biz\model\advertisement;

use Doraemon\pockets\datebase\BaseDbModel;

class MBaseDbModel extends BaseDbModel implements \ArrayAccess
{

    public function __construct($data = []) {
        if (is_array($data)) {
            foreach ($data as $key => $value) {
                $this->{$key} = $value;
            }
        }
    }

    public function __get($key)
    {
        return $this->{$key} ?? null;
    }

    public function __set($key, $value)
    {
        $this->{$key} = $value;
    }

    public function offsetSet($offset, $value) {
        $this->{$offset} = $value;
    }

    public function offsetExists($offset): bool
    {
        return isset($this->{$offset});
    }

    public function offsetUnset($offset) {
        unset($this->{$offset});
    }

    public function offsetGet($offset) {
        return $this->{$offset} ?? null;
    }
}